

var enemyArray:Array;
var enemyPath:Array;
var newEnemyTimer:int = 0;
var startPosition:GameObject;

// enemy types
var enemy2:GameObject;


function Start(){
	
	enemyArray = new Array();
	startPosition = GameObject.Find("EnemyStartingPosition");
	
}

function addEnemy(unit:GameObject){
	enemyArray.push(unit);
}

function removeEnemy(unit:GameObject){
	for(var i:int = 0; i < enemyArray.length; i++){
		if(enemyArray[i] == unit){
			GameObject.Destroy(enemyArray[i]);
			enemyArray.splice(i,1);
		}
	}
}

function Update () {
	
	if(newEnemyTimer > 50){
		createNewEnemy(1);
		newEnemyTimer = 0;
	} else {
		newEnemyTimer++;
	}
}

function createNewEnemy(enemyType:int){
	
	switch (enemyType) {
	
	    case 1:
	        var newEnemy:GameObject = Instantiate(enemy2, startPosition.transform.position, startPosition.transform.rotation);
	        addEnemy(newEnemy);
	        print("enemy added");
	        break;
	    case 2:
	        
	        break;
	    }
	
}
